/*
 * @lc app=leetcode.cn id=1753 lang=golang
 *
 * [1753] 移除石子的最大得分
 */
package Solutions

import "sort"

// @lc code=start
func maximumScore(a int, b int, c int) int {
	arr := [3]int{a, b, c}
	sort.Ints(arr[:])
	a, b, c = arr[0], arr[1], arr[2]
	k := c - b

	t := sort.Search(a, func(i int) bool {
		return k-(a-i)+i >= 0
	})
	return a + (b - t)

}

// @lc code=end
